package servlet;

import service.EmpDeleteServiceImp;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class EmpDeleteServlet extends HttpServlet {
    private EmpDeleteServiceImp empDeleteServiceImp=new EmpDeleteServiceImp();
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String sid = request.getParameter("id");
        int id= Integer.parseInt(sid);

        //调用就通过id删除了数据
        empDeleteServiceImp.delEmp(id);

        //请求转发到员工数据页面
        request.getRequestDispatcher("/empListServlet").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
          doPost(request,response);
    }
}
